package com.hhkj.admin.student.service.base.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hhkj.admin.student.mapper.StudentCourseMapper;
import com.hhkj.admin.student.model.dopo.StudentBatchDo;
import com.hhkj.admin.student.model.dopo.StudentBatchPo;
import com.hhkj.admin.student.model.dopo.StudentPo;
import com.hhkj.admin.student.model.req.StudentBatchReq;
import com.ruoyi.common.base.biz.service.base.BaseServiceImpl;
import com.hhkj.admin.student.domain.Student;
import com.hhkj.admin.student.domain.StudentBatch;
import com.hhkj.admin.student.mapper.StudentBatchMapper;
import com.hhkj.admin.student.service.base.StudentBatchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * 学员批次管理Service业务层处理
 *
 * @author ruoyi
 * @since 2023-05-12
 */
@Service
public class StudentBatchServiceImpl extends BaseServiceImpl<StudentBatch, StudentBatchDo, StudentBatchPo, StudentBatchMapper> implements StudentBatchService {
    @Autowired
    private StudentCourseMapper studentCourseMapper;
    /**
     * 查询学员批次管理列表
     *
     * @param studentBatchReq 学员批次管理
     * @return 学员批次管理集合
     */
    @Override
    public List<StudentBatchPo> selectStudentBatchListByDo(StudentBatchReq studentBatchReq) {
        return this.getBaseMapper().selectStudentBatchListByDo(studentBatchReq);
    }

    /**
     * 查询批次下学员列表
     *
     * @param studentBatchReq 批次号id
     * @return 学员
     */
    @Override
    public List<StudentPo> listBatchStudentPoByDo(StudentBatchReq studentBatchReq) {
        return this.getBaseMapper().listBatchStudentPoByDo(studentBatchReq);
    }

    @Override
    public Long countByToday() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        String date = simpleDateFormat.format(new Date());
        LambdaQueryWrapper<StudentBatch> queryWrapper = new LambdaQueryWrapper<StudentBatch>()
                .ge(StudentBatch::getCreateTime, date);
        return count(queryWrapper);
    }

}
